package com.zyy.seckill.config;

import com.zyy.seckill.entity.User;
import org.springframework.stereotype.Component;

/**
 * @Author: zyy
 * @DateTime: 2021/10/6 14:44
 */
@Component
public class UserContext {
    public static ThreadLocal<User> userHolder =new ThreadLocal<>(); // 可以保证线程之间的隔离

    public static void setUser(User user){
        userHolder.set(user);
    }
    public static User getUser(){
        return userHolder.get();
    }
}
